<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->text('attrs')->comment('货品属性组合');
            $table->unsignedInteger('kucun')->comment('货品的库存数量');
            $table->decimal('addPrice')->comment('附加价格');
            $table->unsignedInteger('goods_id')->comment('对应商品编号');
            //可以给product货品表添加外键约束,这样当删除goods表中的某一条数据后,product表中与之关联的信息mysql数据库也会相应被mysql数据库自动删除
            //我这个外键约束有问题,加上这个外键约束不能执行数据迁移
//            $table->foreign('goods_id')
//                ->reference('id')->on('goods');
//                ->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
